<!-- f r o m 7 5  2 7 1  8 9 2 0 -->
<template>
  <div>
    <a-row :gutter="24">
      <a-col :md="24">
        <a-card ::bordered="false">
          <!-- 查询区域 -->
          <div class="table-page-search-wrapper">
            <!-- 搜索区域 -->
            <a-form layout="inline" @keyup.enter.native="searchQuery">
              <a-row :gutter="24">
                <a-col :md="18" :sm="24">
                  <a-form-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
                    <a-input placeholder="请输入名称查询" v-model="queryParam.name"></a-input>
                  </a-form-item>
                </a-col>
                <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                  <a-col :md="6" :sm="24">
                    <a-button type="primary" @click="searchQuery">查询</a-button>
                    <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
                  </a-col>
                </span>
              </a-row>
            </a-form>
          </div>
          <!-- 操作按钮区域 -->
          <div class="table-operator"  style="margin-top: 5px">
            <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
          </div>
          <!-- table区域-begin -->
          <div>
            <a-table
              ref="table"
              size="small"
              bordered
              rowKey="id"
              :columns="columns"
              :dataSource="dataSource"
              :pagination="ipagination"
              :scroll="scroll"
              :loading="loading"
              @change="handleTableChange">
              <span slot="action" slot-scope="text, record">
                <a @click="handleEdit(record)">编辑</a>
                <a-divider type="vertical" />
                <a-popconfirm title="确定删除吗?" @confirm="() => deleteTemplate(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </span>
            </a-table>
          </div>
          <!-- table区域-end -->
          <!-- 表单区域 -->
          <quote-template-modal ref="modalForm" @ok="modalFormOk"></quote-template-modal>
        </a-card>
      </a-col>
    </a-row>

<!--    <a-row>-->
<!--      <a-card>-->
<!--        <quote-template-item-table ref="quoteTemplateItemTable" ></quote-template-item-table>-->
<!--      </a-card>-->
<!--    </a-row>-->
  </div>
</template>
<!-- BY cao_yu_li -->
<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JDate from '@/components/jeecg/JDate'
  import QuoteTemplateModal from '@views/quote/modules/QuoteTemplateModal.vue'
  import { postAction } from '@api/manage'
  import QuoteTemplateItemTable from '@views/quote/modules/QuoteTemplateItemTable.vue'
  export default {
    name: "QuoteTemplateTable",
    mixins:[JeecgListMixin],
    components: {
      QuoteTemplateItemTable,
      QuoteTemplateModal,
      JDate
    },
    props:{
      // quoteCategoryId:{type:Number,required:true,default:0},
    },
    data () {
      return {
        // localQuoteCategoryId: this.quoteCategoryId,
        localQuoteCategoryId:'',
        selectedRowKeys:[],
        selectionRows:[],
        labelCol: {
          span: 5
        },
        wrapperCol: {
          span: 18,
          offset: 1
        },
        // 查询条件
        queryParam: {name:'',serialNo:'',remark:''},
        // 表头
        columns: [
          {
            title: '操作',
            dataIndex: 'action',
            width: 30,
            align:"center",
            scopedSlots: { customRender: 'action' },
          },
          { title: '名称', dataIndex: 'name', width: 30, align: "left"},
          { title: '材料数量', dataIndex: 'initialAmount', width: 20, align: "left"},
          // { title: '所属分类', dataIndex: 'serialNo', width: 50, align: "left"},
          { title: '备注', dataIndex: 'remark', width: 100, align: "left"},
          // { title: '状态',dataIndex: 'enabled',width:60,align:"center",
          //   scopedSlots: { customRender: 'customRenderEnabledFlag' }
          // }
        ],
        url: {
          list: "/quote/template/table?quoteCategoryId=-1",
          delete: "/quote/template/delete"
        }
      }
    },
    computed: {

    },
    methods: {
      handleEdit: function (record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = "编辑";
        this.$refs.modalForm.disableSubmit = false;
        if(this.btnEnableList.indexOf(1)===-1) {
          this.$refs.modalForm.isReadOnly = true
        }
      },
      handleAdd: function () {
        this.$refs.modalForm.add(this.localQuoteCategoryId);
        this.$refs.modalForm.title = "新增";
        this.$refs.modalForm.disableSubmit = false;
        if(this.btnEnableList.indexOf(1)===-1) {
          this.$refs.modalForm.isReadOnly = true
        }
      },
      deleteTemplate(id) {
        var that = this
        this.$confirm({
          title: '确认删除',
          content: '确定要删除吗?',
          onOk: function () {
            postAction(that.url.delete, {id: id}).then((res) => {
              if (res.code == 200) {
                that.$message.success(res.data.message)
                that.reloadList(that.localQuoteCategoryId)
              } else {
                that.$message.warning(res.data.message)
              }
            })
          }
        })
      },
      reloadList(quoteCategoryId) {
        this.localQuoteCategoryId = quoteCategoryId
        this.url.list = "/quote/template/table?quoteCategoryId="+quoteCategoryId;
        this.loadData();
      },
      // onSelectChange(selectedRowKeys, selectionRows) {
      //   this.selectedRowKeys = selectedRowKeys;
      //   this.selectionRows = selectionRows;
      //   this.$refs.quoteTemplateItemTable.reloadList(this.selectionRows[0])
      // },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>